<?php


/**
 * html Class
 * 
 * This class is used for getting common html elements acros the site for the views 
 * 
 * @author: Victor Nava
 * @author: Eduardo Nava
 *
 */
class html{

	/**
	 * includes the html <head>information
	 */
	function docType(){
		echo '<!DOCTYPE HTML>';
	}

	function head(){
		echo <<<HTML
		<title>Where Is My Beer</title>
		<!--<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>-->
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
		<meta http-equiv="Content-language" content="en" />
		<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
		<script type="text/javascript" src="../lib/jquery.min.js"></script>
		<script type="text/javascript" src="../js/main.js"></script>
		<script type="text/javascript" src="../js/jquery.autoclear.min.js"></script>
HTML;
	}

	/**
	 * includes the html footer
	 */
	function footer(){
		echo <<<HTML
		<div class="footer">
				<a href="router.php">Home</a>&nbsp;
				<a href="router.php">About</a>&nbsp;
		</div>
HTML;
	}
	
	function footer2(){
		echo <<<HTML
		<div id="footer">
		<ul id="footer-nav">
			<li><a href="router.php">Home</a></li>
			<li><a href="router.php?c=about">About</a></li>
		</ul>
		<span id="copyright">Copyright &copy; 2010 The Hungry Guys</span>
	</div>
HTML;
	}

	/**
	 * The navegation bar
	 * @param $user
	 * @return String html
	 */
	//TODO replace with navBar2
	function navBar(){

		$user = isset($_SESSION['user']) ? $_SESSION['user'] : null;

		echo <<<HTML
		<div class="nav-bar">
			<a href="router.php?c=offer">Offers</a>&nbsp;
			<a href="router.php?c=beer">Beers</a>&nbsp;
			<a href="router.php?c=venue">Venues</a>&nbsp;
HTML;
		if($user){
			echo <<<HTML
			<a href="router.php?c=user&a=logout">Logout</a>
			<a href="router.php?c=user">{$user['name']}</a>&nbsp;
HTML;
		}
		else{
			echo <<<HTML
			<a href="router.php?c=user&a=login">Login</a>&nbsp;
			<a href="router.php?c=user&a=register">Register</a>&nbsp;
HTML;
		}
		echo <<<HTML
		</div>
HTML;
	}

	
	/**
	 * Builds and output the html code for the navegation bar
	 * 
	 * @return void
	 */
	function navBar2(){
		$user = isset($_SESSION['user']) ? $_SESSION['user'] : null;

		echo <<<HTML
		
		<div id="header">
		<a href="router.php"><img src="../img/logo-1.png" alt="Where Is My Beer" title="Where Is My Beer" /></a>
		<div id="nav">
			<ul>
				<li><a href="router.php?c=offer">Home</a>&nbsp;</li>
				<li><a href="router.php?c=beer">Beers</a>&nbsp;</li>
				<li><a href="router.php?c=venue">Venues</a>&nbsp;</li>
HTML;
		if($user){
			echo <<<HTML
			<li><a href="router.php?c=user&a=logout">Logout</a></li>
			<!--<li><a href="router.php?c=user">{$user['name']}</a>&nbsp;</li>-->
			<li><a href="">{$user['name']}</a>&nbsp;</li>
HTML;
		}
		else{
			echo <<<HTML
			<li><a href="router.php?c=user&a=login">Login</a>&nbsp;</li>
			<li><a href="router.php?c=user&a=register">Register</a>&nbsp;</li>
HTML;
		}
		echo <<<HTML
		</ul>
		</div>
		</div>
HTML;
	}

	/**
	 * Output a message box at the top when when $_SESSION['flash'] is set
	 *  
	 * @return void
	 */
	function flash(){
		if(isset($_SESSION['flash'])){
			echo "<div class=\"flash\">$_SESSION[flash]</div>";
			unset($_SESSION['flash']);
		}
	}
}
?>